﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Facade;
using IronOne.SalesOne.BusinessObjects;

namespace IronOne.SalesOne.SalesOneWeb.UserControls
{
    public partial class UCGridButtons : System.Web.UI.UserControl
    {

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnView_Click(object sender, EventArgs e)
        {
            string pageUrl = Request.ServerVariables["URL"];
            //string action = "view";
            string id = string.Empty;

            
            //UCUserGrid grd = new UCUserGrid();
            //GridView grdView = (GridView)grd.FindControl("grdUsers");

            id = Session[pageUrl + "view"].ToString();

            switch (pageUrl)
            {
                case "/UserManagement/ManageUsers.aspx":
                    Session["UserAc"] = "view";
                    Response.Redirect("~/UserManagement/AddUser.aspx");
                    break;

                case "/Structure/ManageBranches.aspx":
                    Session["BranchAc"] = "View";
                    Response.Redirect("/Structure/AddBranch.aspx");
                    break;

                case "/Structure/ManageUnits.aspx":
                    Session["UnitAc"] = "View";
                    Response.Redirect("/Structure/AddUnit.aspx");
                    break;


                default:
                    break;
            }

            


            //id = Request.Form["gvradio"].ToString();
            Response.Write(id);
          
                
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string pageUrl = Request.ServerVariables["URL"];

            switch (pageUrl)
            {
                case "/UserManagement/ManageUsers.aspx":
                    Session["UserAc"] = "update";
                    Response.Redirect("~/UserManagement/UpdateUser.aspx");
                    break;

                case "/Structure/ManageBranches.aspx":
                    Session["BranchAc"]="Update";
                    Response.Redirect("/Structure/AddBranch.aspx");
                    break;

                case "/Structure/ManageUnits.aspx":
                    Session["UnitAc"] = "Update";
                    Response.Redirect("/Structure/AddUnit.aspx");
                    break;


                default:
                    break;
            }
            

        }

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            string pageUrl = Request.ServerVariables["URL"];

            switch (pageUrl)
            {
                case "/UserManagement/ManageUsers.aspx":
                    Session["UserAc"] = "create";
                    Response.Redirect("~/UserManagement/AddUser.aspx");
                    break;

                default:
                    break;
            }

        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string pageUrl = Request.ServerVariables["URL"];

            switch (pageUrl)
            {
                case "/UserManagement/ManageUsers.aspx":
                    Session["UserAc"] = "delete";
                    Response.Redirect("~/UserManagement/AddUser.aspx");
                    break;

                 case "/Structure/ManageBranches.aspx":
                      Session["BranchAc"] = "Delete";
                      Response.Redirect("~/Structure/AddBranch.aspx");
                  break;

                 case "/Structure/ManageUnits.aspx":
                  Session["UnitAc"] = "Delete";
                  Response.Redirect("~/Structure/AddUnit.aspx");
                  break;
                 

                default:
                    break;
            }
          
        }



        //public string id
        //{
        //    get
        //    {
        //        return idVal;
        //    }
        //    set
        //    {
        //        idVal = value;
        //    }
        //}
    }
}